package cn.hanna.springcloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author smileha
 * @create 2021-10-20 1:00
 * @description
 */

@EnableBinding(Sink.class)
public class StreamConsumerController {

    @Value("${server.port}")
    private String serverPort;

    @StreamListener(Sink.INPUT)
    public void getMsg(Message<String> message){
        System.out.println("接收到消息："+message.getPayload()+",端口："+serverPort);
    }
}
